<?php

/**
 * Images form.
 *
 * @package    PHOTO_GALLERY
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class ImagesForm extends BaseImagesForm {

    public function configure() {
        $this->useFields(array('image_id', 'name', 'album_id', 'price', 'order_in_album'));
        $this->widgetSchema['image_id'] = new sfWidgetFormInputHidden(array(), array('class'=> 'imgId'));
        $this->widgetSchema['album_id'] = new sfWidgetFormInputHidden(array(), array('class'=> 'albumId'));
        $this->widgetSchema['order_in_album'] = new sfWidgetFormInputHidden(array(), array('class'=> 'order_in_album'));
        
        $this->setDefault('price', 0);

        $fileValidator = new sfValidatorFile();
        $fileValidator->setOption('mime_types', array('image/jpeg', 'image/pjpeg', 'image/png', 'image/x-png', 'image/gif'));
        $fileValidator->setOption('max_size', 519830);
        $fileValidator->setMessage('max_size', 'file too big');
        $fileValidator->setMessage('mime_types', 'file type not supported');

        $this->setWidget( 'file' , new sfWidgetFormInputFile(array(), array('class' => 'fileButton')) );
        
        $this->setValidator(
            'file' , $fileValidator
        );
        $this->getWidgetSchema()->setNameFormat("image[%s]");
        $this->getWidgetSchema()->setAttribute('class', 'imgForm');
        $this->getWidgetSchema()->setAttribute('status', 'empty');
        
        
        $this->validatorSchema->addOption('allow_extra_fields', true);
    }

}
